package api

import (
	"net/http"
	"tool/model"
	"tool/service"

	"gitee.com/xuesongtao/protoc-go-valid/log"
	"github.com/gin-gonic/gin"
)

func Json2Struct(c *gin.Context) {
	var req model.ReqData
	if err := c.BindJSON(&req); err != nil {
		log.Error("c.BindJSON(data) is failed, err: ", err)
		return
	}
	c.JSON(http.StatusOK, service.Json2Struct(&req))
}

func FormatJson(c *gin.Context) {
	var req model.ReqData
	if err := c.BindJSON(&req); err != nil {
		log.Error("c.BindJSON(data) is failed, err: ", err)
		return
	}
	c.JSON(http.StatusOK, service.FormatJson(&req))
}

func Md5(c *gin.Context) {
	var req model.ReqData
	if err := c.BindJSON(&req); err != nil {
		log.Error("c.BindJSON(data) is failed, err: ", err)
		return
	}
	c.JSON(http.StatusOK, service.Md5(&req))
}
